<!--{if $mix_list}-->
<script>
    $(function() {
        $("input:checkbox[name='goods_mix_id']").change(function() {
            var goods_mix_ids = get_goods_mix_id();
            var url = SITE_URL + '/index.php?app=cart&act=max_goods_cart';
            $.getJSON(url, {'goods_mix_ids': goods_mix_ids}, function(data) {
                if (data.done) {
                    $("#max_goods_total_price").html(price_format(data.retval.total_price));
                    $("#max_goods_total_count").html(data.retval.total_count);
                }
                else {
                    alert(data.msg);
                }
            });
        });
    });

    function add_goods_mix()
    {
        var store_id = {$goods.store_id};
        var url = SITE_URL + '/index.php?app=cart&act=max_goods_add';
        var goods_mix_ids = get_goods_mix_id();
        $.getJSON(url, {'goods_mix_ids': goods_mix_ids}, function(data) {
            if (data.done) {
                location.assign(SITE_URL + '/index.php?app=order&goods=cart&store_id=' + store_id);
            }
            else {
                alert(data.msg);
            }
        });
    }

    /**
     * 获取点击事件
     */
    function get_goods_mix_id()
    {
        
        var goods_mix_ids = "";
        $("input:checkbox[name='goods_mix_id']:checked").each(function(i) {
            if (0 == i) {
                goods_mix_ids = $(this).val();
            } else {
                goods_mix_ids += ("," + $(this).val());
            }
        });
        return goods_mix_ids;
    }
</script>
<div class="goods_relation clearfix">
    <div class="mt">
        <h2>{$lang.match_purchase}</h2>
    </div>
    <div class="mc clearfix">
        <ul>
            <input type="checkbox"  name="goods_mix_id" value="{$goods.default_spec}" checked="checked" style="display:none">
            <!--{foreach from=$mix_list item=mix_item name=fe_mix_item}-->
            <li id="mix_item_{$mix_item.cate_id}">
                <label>
                    <div class="p-img">
                        <img src="{$site_url}/{$mix_item.default_image}">
                    </div>
                    <div class="p-name">
                        {$mix_item.goods_name|escape}
                    </div>
                    <div class="p-price">
                        <input type="checkbox" name="goods_mix_id" value="{$mix_item.default_spec}" >
                        <strong>{$mix_item.price|price}</strong>
                    </div>
                </label>
            </li>
            <!--{/foreach}-->
        </ul>
    </div>
    <div class="mb">
        <div class="p-name"></div>
        <div class="p-price">{$lang.hava_choosed}：<strong id="max_goods_total_count">0</strong>个&nbsp;&nbsp;{$lang.With_price}：<strong id="max_goods_total_price">{$goods.price|price}</strong></div>
        <div class="btns"><a href="javascript:add_goods_mix()">{$lang.purchase_now}</a></div>
    </div>
</div>
<!--{/if}-->
